home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7458 < prev    next >
Encoding:
Text File  |  1996-08-05  |  11.4 KB  |  373 lines

  1. Newsgroups: comp.lang.c,comp.lang.c.moderated,misc.books.technical,alt.books.technical
  2. Path: aw.com!summit
  3. From: summit@aw.com (Steve Summit)
  4. Subject: Errata for C Programming FAQs by Steve Summit
  5. Message-ID: <DnED2E.ME3@aw.com>
  6. Followup-To: comp.lang.c
  7. X-Pgp-Signature: Version: 2.6
  8.     iQCSAwUBMTIFUN6sm4I1rmP1AQHFLAPnVAU100F9sff5kEZbv47pzHhNDDQ6/F1x
  9.     NoO3HphD+MsibqmG/c45MjzUTz0BLFFj5VuO7DHY/owgHP13TpsRZa+DvHKeBjxm
  10.     jwBe4Wf0e4sZZZ5PKcVqc3luPE240/50r5smJcUo3tg1HU0ILlMIdpGYdznYi1I3
  11.     RFLgRZk=
  12.     =qsuZ
  13. Organization: schmorganization
  14. Date: Mon, 26 Feb 1996 19:06:14 GMT
  15. Approved: scs@eskimo.com
  16.  
  17. [I'm posting this to several newsgroups, but followups are
  18. redirected to comp.lang.c.]
  19.  
  20. Errata list for "C Programming FAQs: Frequently Asked Questions",
  21. by Steve Summit, Addison-Wesley, 1996, ISBN 0-201-84519-9
  22. (first printing).
  23.  
  24. A possibly more up-to-date copy of this errata list may be
  25. obtained at any time by anonymous ftp from ftp.eskimo.com
  26. in the file ~scs/C-faq/book/Errata, or on the web at
  27. http://www.eskimo.com/~scs/C-faq/book/Errata.html .
  28. (If you read this years from now and those addresses don't
  29. work, try ftp://ftp.aw.com/cseng/authors/summit/cfaq/ or
  30. http://www.aw.com/cseng/authors/summit/cfaq/cfaq.html .)
  31.  
  32. scs 2/26/1995
  33.  
  34.  
  35. page    question
  36. ----    --------
  37.  
  38. front cover    The ladder has no rungs.
  39.  
  40. xxix        "woundn't" should be "wouldn't"
  41.  
  42. 2    1.1    Interpreted as a C expression,
  43.  
  44.             sizeof(char) <= sizeof(short) <= sizeof(int) <=
  45.                             sizeof(long)
  46.  
  47.         is vacuously true (see question 3.13).  The intent,
  48.         of course, is a mathematical relation, which might
  49.         be more apparent if real less-than-or-equal signs
  50.         were used instead of <=.
  51.         [Thanks and $1 to Mark Brader]
  52.  
  53. 6    1.7    There may be zero definitions of an external
  54.         function or variable that is not referenced
  55.         in any expression.
  56.         [Thanks and $1 to James Stern]
  57.  
  58. 7    1.7    "use include to bring" should be
  59.         "use #include to bring"
  60.  
  61. 11    1.14    In the second fix, at the bottom of the page,
  62.         it could conceivably be necessary to precede
  63.         the line
  64.  
  65.             typedef struct node *NODEPTR;
  66.  
  67.         with the line
  68.  
  69.             struct node;
  70.  
  71.         for the reason mentioned on page 13, although
  72.         in that case one of the two other fixes would
  73.         clearly be preferable.
  74.         [Thanks to James Stern]
  75.  
  76. 13    1.15    In the alternate fix, at the bottom of the page,
  77.         it could conceivably be necessary to precede
  78.         the typedef declarations with the lines
  79.  
  80.             struct a;
  81.             struct b;
  82.  
  83.         although again, putting those typedefs after the
  84.         complete structure definitions would clearly be
  85.         preferable in that case.
  86.         [Thanks to James Stern]
  87.  
  88. 18    1.22    The odd "return 0;" line is not really necessary.
  89.  
  90. 20    1.24    Another possible arrangement is
  91.  
  92.             /* file1.h */
  93.             #define ARRAYSZ 3
  94.             extern int array[ARRAYSZ];
  95.  
  96.             /* file1.c */
  97.             #include "file1.h"
  98.             int array[ARRAYSZ];
  99.  
  100.             /* file2.c"
  101.             #include "file1.h"
  102.  
  103.         [Thanks to Jon Jagger]
  104.  
  105. 23    1.29    [2nd bullet] "everything else termed" should be
  106.         "everything else, termed"
  107.  
  108. 24    1.29    [Rule 3] "if the header" should be "if any header".
  109.         [Thanks and $1 to James Stern]
  110.  
  111. 24    1.29    [Rule 4] "(i.e., function names)" should be
  112.         "(e.g., function names)".
  113.         [Thanks and $1 to James Stern]
  114.  
  115. 24    1.29    The text at the bottom of the page suggests that
  116.         "future directions" name patterns such as str[a-z]*
  117.         are reserved only if their corresponding headers
  118.         (e.g. <stdlib.h>) are included.  The reserved
  119.         function names are unconditionally reserved;
  120.         it is only the macro names that are reserved only
  121.         if the header is included.
  122.         [Thanks and $1 to Mark Brader]
  123.  
  124. 25    1.29    "if you don't include the header files" should be
  125.         "if you don't include any header files".
  126.  
  127. 32    2.4    Besides -> and sizeof, the . operator, as well as
  128.         declarations of actual structures, also require
  129.         the compiler to know more about the structure and
  130.         so preclude incomplete or hidden definitions.
  131.         [Thanks to James Stern]
  132.  
  133. 40    2.12    When trying to minimize wasted space in structures,
  134.         array members should be ordered based on the size
  135.         of their primitive types, not their overall size.
  136.         [Thanks and $1 to James Stern]
  137.  
  138. 43    2.20    "ANSI/SIO" should be "ANSI/ISO"
  139.  
  140. 50    3.3    Of course, another way to increment i is i += 1.
  141.         [Thanks to James Stern]
  142.  
  143. 51    3.4    "higher precedence than *):" should be
  144.         "higher precedence than *:"
  145.  
  146. 52    3.6    Delete the close parenthesis at the end of the answer.
  147.  
  148. 57    3.12    In C++, the preincrement form ++i is preferred.
  149.         [Thanks to James Stern]
  150.  
  151. 84    5.8    Either the comma or the parentheses in the answer
  152.         should be changed.
  153.  
  154. 95    6.2    The typography in the following line is inconsistent
  155.         for the "x" of "x[3]".
  156.  
  157. 115    7.1    The close parenthesis and period ")." at the bottom
  158.         of the page are not part of the #define line.
  159.  
  160. 136    8.1    "Although string literal" should be
  161.         "Although a string literal"
  162.  
  163. 136    8.2    C can be tricked into seeming to assign an array
  164.         as a whole if you hide the array inside a
  165.         structure or union.
  166.         [Thanks and $1 to James Stern]
  167.  
  168. 143    9.2    The example variable isvegetable should perhaps
  169.         be named is_vegetable to avoid naming conflicts
  170.         (see question 1.29).
  171.         [Thanks and $1 to Jon Jagger]
  172.  
  173. 151    10.4    Extra space in "/* (no trailing ; ) */".
  174.  
  175. 152    10.6    [paragraph below bullets] "bring the header wherever"
  176.         should be "bring the header in wherever"
  177.  
  178. 158    10.15    If you have to, you can #define a companion macro
  179.         name for each typedef, and use #ifdef with that.
  180.         [Thanks to James Stern]
  181.  
  182. 161    10.21    The suggested replacement macros should all
  183.         parenthesize c:
  184.  
  185.             #define CTRL(c) ((c) & 037)
  186.             #define CTRL(c) (*#(c) & 037)
  187.             #define CTRL(c) (#(c)[0] & 037)
  188.  
  189.         [Thanks and $1 to James Stern]
  190.  
  191. 164-5    10.27    The file parameter of the dbginfo() function and
  192.         the fmt parameter of the debug() function could
  193.         be of type const char *.
  194.         [Thanks to James Stern]
  195.  
  196. 174    11.10    As written, the "complicated series of assignments"
  197.         includes one initialization.
  198.         [Thanks to James Stern]
  199.  
  200. 175    11.10    "e.g., (const char) ** in this case" should be
  201.         "e.g., (const char **) in this case"
  202.  
  203.         "when the pointers which" should either be
  204.         "when the pointers" or "with pointers which"
  205.  
  206. 180    11.19    "questions 20.20" should be "question 20.20"
  207.  
  208. 182    11.25    "The function offers" should be
  209.         "The memmove function offers".
  210.         [Thanks and $1 to Gordon Burditt]
  211.  
  212. 186    11.29    You may also need to rework calls to realloc
  213.         that use null or 0 first or second arguments
  214.         (see question 7.30).
  215.  
  216. 186    11.29    You may also need to rework conditional compilation
  217.         involving #elif.
  218.         See also the Rationale's list of "Quiet Changes"
  219.         (see question 11.2).
  220.         [Thanks to James Stern]
  221.  
  222. 189    11.33    A fourth class of behavior is locale-specific.
  223.         [Thanks and $1 to James Stern]
  224.  
  225. 198    12.11    A semicolon is missing after "int i = 0".
  226.  
  227.         The } just before the line "*p = '\0'" is
  228.         indented one tab too few.
  229.  
  230.         Two instances of "*--p" have the minus signs merged
  231.         so as to appear as one.
  232.  
  233. 201    12.16    [case 2] The variable line is not declared;
  234.         it might be char * or char [].
  235.         [Thanks and $1 to James Stern]
  236.  
  237. 205    12.19    There's an extraneous double quote in what
  238.         should be "intervening whitespace:".
  239.  
  240. 207-8    12.21    The technique of writing to a file may give the
  241.         wrong answer if the disk fills up.
  242.         [Thanks and $1 to Mark Brader]
  243.  
  244. 212    12.28    The answer is in the wrong font.
  245.  
  246. 224    13.4    "upper- or lowercase" should probably be
  247.         "upper or lower case".
  248.  
  249. 225    13.6    Since the fragment calls printf, it must
  250.         #include <stdio.h>.
  251.         [Thanks and $1 to James Stern]
  252.  
  253. 226    13.6    [last code fragment] A declaration and initialization
  254.  
  255.             char string[] = "this\tis\t\ta\ttest";
  256.  
  257.         similar to the one on p. 225 should appear.
  258.         [Thanks and $1 to Doug Liu]
  259.  
  260. 234    13.14    "time_ts" should perhaps be "time_t's"
  261.  
  262. 244    13.21    If you're not familiar with the notation [0, 1),
  263.         it means that drand48() returns a number x
  264.         such that 0 <= x and x < 1.
  265.  
  266. 250    14.5    The expression
  267.  
  268.             fabs(a - b) <= epsilon * a
  269.  
  270.         performs poorly if a == 0.0 (which is another
  271.         argument in favor of "mak[ing] the threshold
  272.         a function of b, or of both a and b").
  273.  
  274. 253    14.9    The name isnan() is a potential namespace conflict
  275.         (see question 1.29), although it's a de facto
  276.         standard in some environments.
  277.         [Thanks to Jon Jagger]
  278.  
  279. 260-1    15.4    The first argument to vstrcat() could be const char *,
  280.         as could the fmt argument to miniprintf().
  281.         [Thanks to James Stern]
  282.  
  283. 264    15.5    The fmt argument to error() could be const char *.
  284.  
  285. 269-71    15.12    The fmt arguments to faterror(), verror(), and
  286.         error(), and could all be const char *.
  287.  
  288. 274    16.4    [point 2] The problem could be caused by a setbuf
  289.         or setvbuf buffer local to any function.
  290.         [Thanks and $1 to James Stern]
  291.  
  292. 287    18.1    The URL in the list of metrics tools is really
  293.         "http://www.qucis.queensu.ca:1999/Software-Engineering/Cmetrics.html".
  294.  
  295. 294    18.13    The conventional spelling is "NetBSD".
  296.         [Thanks and $1 to Peter Seebach]
  297.  
  298. 294    18.14    Extra space in site which should be "sunsite.unc.edu".
  299.  
  300. 296    18.16    Extra space in address which should be
  301.         "archie@archie.cs.mcgill.ca".
  302.  
  303. 324    19.42    "control characters, such as" should be
  304.         "control characters such as"
  305.  
  306. 339-40        The page break makes the code very hard to follow.
  307.  
  308. 346    20.17    Missing tab in line which should be
  309.  
  310.             #define CODE_NONE    0
  311.  
  312. 350    20.21    The overbars are misaligned.
  313.  
  314. 355    20.29    "and computes that number" should either be
  315.         "computed" or "and is computed".
  316.  
  317. 368        [parameter] Extraneous semicolon at end of
  318.         line which should be
  319.  
  320.             f(int i)
  321.  
  322. 370-1        The glossary entry for "undefined" is misplaced.
  323.         [Thanks and $1 to James Stern]
  324.  
  325. 376        The two minus signs in the index entry for
  326.         "-- operator" overlap and appear to be one.
  327.  
  328. 379        The pairs of underscores in the index entry for
  329.         "__FILE__ macro" overlap and might appear to be one.
  330.  
  331. 382        The pairs of underscores in the index entry for
  332.         "__LINE__ macro" overlap and might appear to be one.
  333.  
  334. back cover    "on the Usenet/Internet on the C FAQ" is muddled
  335.         and should say something else.
  336.  
  337.         "com.lang.c" should be "comp.lang.c".
  338.  
  339.         The ftp address for source code should be
  340.         ftp://ftp.aw.com/cseng/authors/summit/cfaq .
  341.  
  342.             *    *    *
  343.  
  344. [P.S. To several of the above errors, I'd like to append a
  345. special if gratuitous apology for my friends in comp.lang.c.
  346. The errors in the text are the errors in the text; as the preface
  347. says, "it can be as hard to eradicate the last error from a large
  348. manuscript as it is to stamp out the last bug in a program."  The
  349. errors in the code fragments, though, are particularly painful.
  350. As any of you discover any more errors, either in the text or
  351. the code, you're welcome and urged to send them to me.
  352. (The code from the book which is available at ftp.aw.com and
  353. ftp.eskimo.com is correct.)
  354.  
  355. You may be asking, "Why do so many programming books have errors
  356. in the source code?  Why don't book authors take the obvious steps
  357. of compiling the code fragments to test them, and of pasting them
  358. into the manuscript in an automated way to eliminate typographical
  359. errors?"  As a matter of fact, and for what it's worth, I *did*
  360. compile most of those code fragments to test them, and on a
  361. couple of machines, and I went to some trouble to cause them to
  362. be read directly and automatically into the manuscript.  But
  363. the manuscript, though I submitted it electronically, was not
  364. in camera-ready form (if there's a next time, it will be!), which
  365. meant that a small army of compositors, not under my control and
  366. not sufficiently sensitive to the peculiarities of C source code,
  367. ran roughshod over it, but I, thinking that the code fragments
  368. were finished, didn't always proofread the galleys carefully
  369. enough to detect the errors that the compositors had introduced. 
  370. This tawdry tale does not excuse the errors, which I do apologize
  371. for, but I offer it here in the hopes that y'all won't think that
  372. I'm irredeemably irresponsible.  --scs]
  373.